Clear["Gloab`*"];

(*动态轨迹——包括线条和残影*)
Animate[
 ball = Graphics[{
    Table[
     x = t + p;(*p是时间偏移量*)
     y = -0.1*x^2 + 1*x + 2;
     sol = Solve[-0.1*m^2 + 1*m + 2 == 0, {m}];
     {Opacity@If[t + p < 0.001, 0, p], PointSize@0.02, Hue[0.6], 
      Point[{x, y}]
      }, {p, 0, 0.5, 0.05}],
    
    Text["t+p=" <> ToString@t, {11, 6}, {-1, 0}],
    Text["方程" <> ToString@eq, {11, 7}, {-1, 0}]
    }, PlotRange -> {{-1, 13}, {0, 5}},
   GridLines -> {{sol}, None},
   Axes -> True, ImagePadding -> 30
   ],
 {t, -0.5 + 0.001, 12, 0.1}, AnimationRunning -> False
 ]


(*字符串转换表达式*)
plotFunc[var0_, expr0_] := Module[{var = var0, expr = expr0},
   myvar = ToExpression@var;
   myexpr = ToExpression@expr;
   Print@("函数为：y=" <> ToString@InputForm@myexpr);
   Print@("函数零点为：" <> ToString@Solve[myexpr == 0, {myvar}]);
   Print@"函数图像如下：";
   Print@Plot[myexpr, Evaluate@{myvar, -5, 5}]
   ];

var = "x";
expr = "-1.*x^2+2";
varm = "m";
exprm = StringReplace[expr, "x" -> "m"];
plotFunc[varm, exprm]
